خرید بک لینک

Vote count: 0

In Java OWL API, equivalent classes can be added using OWLEquivalentClassesAxiom. Is there any similar class for adding OWL SameAs axiom?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 22:57

Vote count: 0

So i was ask to make a function that determinate if a number is a perfect square but it has a catch they ask me to operate using an auxiliary function that i should write based on this fact:

The first perfect square is 0, to get to the second i need to add up 1 (the second perfect square is 1), to get to the third i need to add up 3 (the third perfect square is 4), and so on ... so the rule is that as you keep adding odd numbers to the previous perfect square you get the next one.

Also they ask me to avoid using operations that involve float numbers.

I wasnt able to make any progress with it i hope someone could help me, thanks.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 22:57

Vote count: 0

I would appreciate if you could help me with this little problem. I have this dataframe:

> dxmale
  Var1 Freq
1  F20    1
2  F25    3
3  F31    1
4  F32    5
5  F33    9
6  F34    3
7  F41    3

The problem is I want the "Var1" column to be the variables, like if it was a table. I want this in order to merge this dataframe with other. I would like to obtain something like this:

> dxmale
   F20 F25 F31 F32 F33 F34 F41
    1   3   1   5   9   3   3

Thanks for your help

asked 52 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 22:57

Vote count: 0

I have a txt file:

1,6 2 6,5 5 ...  // ~ 1000 columns 
0 1 4 2,5 ...
... // ~1000 rows

that is, "," instead "."

How to read this?

1.6 2 6 5 ...
0 1 4 2.5 ...
...

Many thanks!

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 21:54

Vote count: 0

I have a UISearchController with a tableview which displays the searched PFusers from Parse. When the user tab on a row, the cell will segue to another view controller displaying info about the PFUser. The segued view controller has a button to unwind segue back to the tableview. The problem happens when I segue back to the tableviewcontroller; the tableviewcontroller is no longer like it was before I segue to another view controller (the searched PFUsers are gone, the table is empty) and when I search again, no results are fetched but I can see it is using data because of the spier on the battery status bar. Any idea why this is happening? thanks!

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 21:54

Vote count: 0

Preface: I do understand the standard definition for attr_accessor and know that attr_accessor stands for two instance methods-a setter and a writer, and attr_accessor allows instances variables to be accessible throughout the class.

But now and then I see an element included in attr_accessor AND is defined as a method.

So my question is: Why does that happen? Is it just bad code I saw?

Pseudo/example code:

class Such_n_such
    attr_accessor :name, :color  
            #code omitted
       def color=(color)
         (some code)
       end

Thanks in advance!

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 21:54

Vote count: 416

I am ruing a PHP script, and keep getting errors like:

Undefined variable: user_location in C:wampwwwmypathindex.php on line 12

Line 12 looks like this:

$greeting = "Hello, ".$user_name." from ".$user_location;

What do these errors mean?

Why do they appear all of a sudden? I used to use this script for years and I've never had any problem.

What do I need to do to fix them?

Is there a quick fix?

This is a General Reference question for people to link to as duplicate, instead of having to explain the issue over and over again. I feel this is necessary because most real-world answers on this issue are very specific.

Related Meta discussion:

community wiki

14 Answers

Vote count: 422 accepted

From the vast wisdom of the PHP Manual:

Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals tued on. E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized.

Some explanations:

Although PHP does not require variable declaration, it does recommend it in order to avoid some security vulnerabilities or bugs where one would forget to give a value to a variable that he will use later in the script. What PHP does in the case of undeclared variables is issue a very low level error, E_NOTICE, one that is not even reported by default, but the Manual advises to allow during development.

Ways to deal with the issue:

  1. Recommended: Declare your variables. Or use isset() to check if they are declared before referencing them, as in: $value = isset($_POST['value']) ? $_POST['value'] : '';.

  2. Use empty(), so no waing is generated if the variable does not exist. It's equivalent to !isset($var) || $var == false. E.g.

    echo "Hello " . (!empty($user) ? $user : "");
    
    
  3. Set a custom error handler for E_NOTICE and redirect the messages away from the standard output (maybe to a log file). set_error_handler('myHandlerForMinorErrors', E_NOTICE | E_STRICT).

  4. Disable E_NOTICE from reporting. A quick way to exclude just E_NOTICE is error_reporting( error_reporting() & ~E_NOTICE ).

  5. Suppress the error with the @ operator.

Note: It's strongly recommended to implement just point 1.

Related:

community wiki

Vote count: 48

Try these

Q1: this notice means $vaame is not defined at current scope of the script.

Q2: Use of isset(), empty() conditions before using any suspicious variable works well.

// recommended solution
$user_name = $_SESSION['user_name'];
if (empty($user_name)) $user_name = '';

OR 

// just define at the top of the script index.php
$user_name = ''; 
$user_name = $_SESSION['user_name'];

OR 

$user_name = $_SESSION['user_name'];
if (!isset($user_name)) $user_name = '';

QUICK Solution:

// not the best solution, but works
// in your php setting use, it helps hiding site wide notices
error_reporting(E_ALL ^ E_NOTICE);


Note about sessions:

community wiki

Vote count: 19

A (often discouraged) alteative is the error suppression operator @. It is a specific language construct to shut down undesired notices and waings, but should be used with care.

First, it incurs a microperformance penalty over using isset. That's not measurable in real world applications, but should be considered in data heavy iterations. Secondly it might obstruct debugging, but at the same time suppressed errors are in fact passed on to custom error handlers (unlike isset decorated expressions).

community wiki

Vote count: 15

It means you are testing, evaluating, or printing a variable that you have not yet assigned anything to. It means you either have a typo, or you need to check that the variable was initialized to something first. Check your logic paths, it may be set in one path but not in another.

community wiki

Vote count: 12

Generally because of "bad programming", and a possibility for mistakes now or later.

  1. If it's a mistake, make a proper assignment to the variable first: $vaame=0;
  2. If it really is only defined sometimes, test for it: if (isset($vaame)) .... before using it
  3. If it's because you spelled it wrong, just correct that
  4. Maybe even tu of the waings in you PHP-settings
community wiki

Vote count: 10

I didn't want to disable notice because it's helpful, but wanted to avoid too much typing.

My solution was this function:

function ifexists($vaame)
{
  retu(isset($$vaame)?$vaame:null);
}

So if I want to reference to $name and echo if exists, I simply write:

<?=ifexists('name')?>

For array elements:

function ifexistsidx($var,$index)
{
  retu(isset($var[$index])?$var[$index]:null);
}

In page if I want to refer to $_REQUEST['name']:

<?=ifexistsidx($_REQUEST,'name')?>

community wiki

Vote count: 8

The best way for getting input string is:

$value = filter_input(INPUT_POST, 'value');

This one-liner is almost equivalent to:

if (!isset($_POST['value'])) {
    $value = null;
} elseif (is_array($_POST['value'])) {
    $value = false;
} else {
    $value = $_POST['value'];
}

If you absolutely want string value, just like:

$value = (string)filter_input(INPUT_POST, 'value');

community wiki

Vote count: 7

Its because the variable '$user_location' is not getting defined. If you are using any if loop inside which you are declaring the '$user_location' variable then you must also have an else loop and define the same. For example:

$a=10;
if($a==5) { $user_location='Paris';} else { }
echo $user_location;

The above code will create error as The if loop is not satisfied and in the else loop '$user_location' was not defined. Still PHP was asked to echo out the variable. So to modify the code you must do the following:

$a=10;
if($a==5) { $user_location='Paris';} else { $user_location='SOMETHING OR BLANK'; }
echo $user_location;

community wiki

Vote count: 5

I used to curse this error, but it can be helpful to remind you to escape user input.

For instance, if you thought this was clever, shorthand code:

// Echo whatever the hell this is
<?=$_POST['something']?>

...Think again! A better solution is:

// If this is set, echo a filtered version
<?=isset($_POST['something']) ? html($_POST['something']) : ''?>

(I use a custom html() function to escape characters, your mileage may vary)

community wiki

Vote count: 4

the quick fix is to assign your variable to null at the top of your code

$user_location = null;

community wiki

Vote count: 3

I use all time own useful function exst() which automatically declare variables.

Your code will be -

$greeting = "Hello, ".exst($user_name, 'Visitor')." from ".exst($user_location);


/** 
 * Function exst() - Checks if the variable has been set 
 * (copy/paste it in any place of your code)
 * 
 * If the variable is set and not empty retus the variable (no transformation)
 * If the variable is not set or empty, retus the $default value
 *
 * @param  mixed $var
 * @param  mixed $default
 * 
 * @retu mixed 
 */

function exst( & $var, $default = "")
{
    $t = "";
    if ( !isset($var)  || !$var ) {
        if (isset($default) && $default != "") $t = $default;
    }
    else  {  
        $t = $var;
    }
    if (is_string($t)) $t = trim($t);
    retu $t;
}

community wiki

Vote count: 3

In a very Simple Language.
The mistake is you are using a variable $user_location which is not defined by you earlier and it doesn't have any value So I recommend you to please declare this variable before using it, For Example:


$user_location = '';
Or
$user_location = 'Los Angles';
This is a very common error you can face.So don't worry just declare the variable and Enjoy Coding.
community wiki

Vote count: -1

why not keep things simple?

<?php
error_reporting(E_ALL); // making sure all notices are on

function idxVal(&$var, $default = null) {
         retu empty($var) ? $var = $default : $var;
  }

echo idxVal($arr['test']);         // retus null without any notice
echo idxVal($arr['hey ho'], 'yo'); // retus yo and assigns it to array index, nice

?>

community wiki

Vote count: -1

Short Tag gotcha.

Included a file having a variable & using the variable in calling file. The Notice will occur $variable is undefined.

The reason for that was is short tags are disabled and the code instead of would not work.

The code would never executed in short tags hence the undefined variable error/notice. Disabled by default in php7

community wiki

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 20:41

Vote count: 0

I am trying to do some hacking (I need to run the linker on a device to link some object files stored there) during the linking stage of Xcode on my ios app project. My first thought is to use the open-source lld linker to replace the native ld linker. I tried to replace ld with lld in the default xcode toolchain, and sent the same arguments to lld, but unfortunately many arguments are not recognized. If I remove these arguments, I get errors like:

Assertion failed : (dylib.file), function exports, file / var / root / Desktop / llvm / tools / lld / lib / ReaderWriter / MachO / File.h, line 302.
0  lld                      0x00000001082043ee llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1  lld                      0x0000000108204829 PrintStackTraceSignalHandler(void*) + 25
2  lld                      0x0000000108201029 llvm::sys::RunSignalHandlers() + 425
3  lld                      0x0000000108204b89 SignalHandler(int) + 345
4  libsystem_platform.dylib 0x00007fff86d1ceaa _sigtramp + 26
5  lld                      0x000000010bc5cd9b SentinelFragment + 491531
6  lld                      0x000000010820484b raise + 27
7  lld                      0x0000000108204902 abort + 18
8  lld                      0x00000001082048e1 __assert_rtn + 129
9  lld                      0x000000010a557111 lld::mach_o::MachODylibFile::exports(llvm::StringRef, llvm::StringRef) const + 1617
10 lld                      0x000000010a55717a lld::mach_o::MachODylibFile::exports(llvm::StringRef, llvm::StringRef) const + 1722
11 lld                      0x000000010a556445 lld::mach_o::MachODylibFile::exports(llvm::StringRef, bool) const + 101
12 lld                      0x000000010ab94088 lld::Resolver::handleSharedLibrary(lld::File&)::$_1::operator()(llvm::StringRef, bool) const + 104
13 lld                      0x000000010ab9400b void std::__1::__invoke_void_retu_wrapper<void>::__call<lld::Resolver::handleSharedLibrary(lld::File&)::$_1&, llvm::StringRef, bool>(lld::Resolver::handleSharedLibrary(lld::File&)::$_1&&&, llvm::StringRef&&, bool&&) + 139
14 lld                      0x000000010ab93f4c std::__1::__function::__func<lld::Resolver::handleSharedLibrary(lld::File&)::$_1, std::__1::allocator<lld::Resolver::handleSharedLibrary(lld::File&)::$_1>, void(llvm::StringRef, bool)>::operator()(llvm::StringRef&&, bool&&) + 76
15 lld                      0x000000010ab9456e std::__1::function<void(llvm::StringRef, bool)>::operator()(llvm::StringRef, bool) const + 94
16 lld                      0x000000010ab8cc7f lld::Resolver::forEachUndefines(lld::File&, bool, std::__1::function<void(llvm::StringRef, bool)>) + 591
17 lld                      0x000000010ab8d213 lld::Resolver::handleSharedLibrary(lld::File&) + 179
18 lld                      0x000000010ab8e4be lld::Resolver::resolveUndefines() + 1518
19 lld                      0x000000010ab913cc lld::Resolver::resolve() + 108
20 lld                      0x0000000108000413 lld::Driver::link(lld::LinkingContext&, llvm::raw_ostream&) + 5795
21 lld                      0x0000000107feec9d lld::DarwinLdDriver::linkMachO(llvm::ArrayRef<char const*>, llvm::raw_ostream&) + 221
22 lld                      0x0000000108034f99 lld::UniversalDriver::link(llvm::MutableArrayRef<char const*>, llvm::raw_ostream&) + 1081
23 lld                      0x0000000107fe960e main + 94
24 libdyld.dylib            0x00007fff98c385ad start + 1

I think it's because lld maybe not a direct replacement for ld. Then I am thinking is it possible to first link multiple object files into a single object file with lld (and do the hacking during this step) using -r option and then do the full link with ld?

So, my question is, is that possible to replace mac ld with lld? If not possible to fully replace it, is that possible to use lld to generate a single intermediate single object file and then input it to ld?

Thanks so much!

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 20:41

Vote count: 0

I have an SKEmitterNode in SpriteKit. I Added a separate .sks file and even replaced the standard texture with a red spark. Then I added it to my bird node. I see red sparks coming out of it, But only on the Black Burton out. My SKScene in background color is white and I can only see the sparks on dark background

Emitter node has the parent bird

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 20:41

Vote count: 0

I have this script

#!/bin/bash

rename_files() {
   title="${1##*${2} - }"
   for filename in "$1/"*.*; do
   case "${filename##*.}" in
     doc|doc|doc)
       mkdir -p -m 777 "/Users/Desktop/Documents Share/Downloaded/${title}"
       new_path="/Users/Desktop/Documents Share/Downloaded/${title}/${title}.${filename##*.}"
       let "iters=1"
       while [ -f $new_path ] ; do
          new_path=$new_path"$iters"
          let "iters++"
       done
       echo "moving $filename -> $new_path"
       mv "${filename}" "${new_path}"
       ;;
   esac
   done
}

rename_category() {
  for path in "/Users/Desktop/Documents Share/Downloads/${1}"*; do
    rename_files "$path" "$1"
  done
}

rename_category DOC

This script automatically moves and renames files contained in /Users/Desktop/Documents Share/Downloaded. All is working fine if I use a folder called Documents instead of Documents Share. I tried to do use Documents Share but it doesn't work.

Here is the error log

/Users/Desktop/Script.sh: line 11: [: /Users/Desktop/Documents: binary operator expected

How can I solve it?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 18:22

Vote count: 0

i need ur help figuring out this problem... im new to angular just started playing on ground.

Initially i have only one button on load "Add list", with add list user can able to add multiple lists with itself have a button("Add Phase") for each list, on click of Add phase it should show the content related to that phase.

Im doing this all in dynamic way.

My HTML looks like:

<button ng-click="list()">add list</button>

<div id="container"></div>

My controller looks like:

    $scope.list =function(){
    var name1html = '<div id="ide"><button ng-click="phase()">Add Phase</button><div id="drop"></div></div>';
    var name1 = $compile(name1html)($scope);
    angular.element(document.getElementById('container')).append(name1);
    }


    $scope.phase =function(){

    var name2html = '<div>123</div>';
    var name2 = $compile(name2html)($scope);
    angular.element(document.getElementById('drop')).append(name2);

    }

Actual Output: On click of 2nd Add phase button it is again adding to 1st button

Expected Output: Im expecting something like this

asked 16 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 18:22

Vote count: 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: uploadimg

Filename: models/upload_model.php

Line Number: 26

/my code/ Controller

public function do_upload(){
    $this->upload->do_upload();
    if($this->upload_model->Doupload()){
        echo 1;
    }else{
        echo 0;
    }
}
 private function set_config_option(){
    $config =array(
        'allowed_type' => 'gif|jpg|png|jpeg|pdf|doc|xml|zip|rar',
        'file_size'  => '100',
        'max_width'  => '1024',
        'overwrite'  => TRUE,
        'max_height' => '768',
    );
    retu $config;
}

Model

 private function set_config_option(){
    $config =array(
        'allowed_type' => 'gif|jpg|png|jpeg|pdf|doc|xml|zip|rar',
        'file_size'  => '2048000',
        'max_width'  => '1024',
        'overwrite'  => TRUE,
        'max_height' => '768'
    );
    retu $config;
}

public function Doupload(){



    $target_path = 'uploads/';
    $target_file = $target_path. basename($_FILES['uploadimg']['name']);
    $base_url = base_url();
    $img_title = $this->input->post('imgname');

    $this->upload->initialize('upload', $this->set_config_option());
  //  $img = $this->upload->do_upload();    
   }

Please help me...

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 17:11

Vote count: 0

Suppose there is a scenario of Users having Tasks. Each User can either be a Watcher or Worker of a Task.

Furthermore, a Worker can file the hours he has worked on a given Task.

Would the following diagram be correct? I have looked around at domain models and I have not seen one with the two associations (works on, watches). Is it acceptable?

enter image description here

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 17:11

Vote count: 0

I was reading the book "Text Analysis with R for Students of Literature" and trying to reproduce the example. Therefore I have a vector in which every element is one line of text from a book and I am now attempting to merge these into a vector of the length one with the past() function. I have tried to play around with the arguments and read about it but no matter what, the resulting vector keeps the original length. I am using R studio 0.99.484 with R 3.2.3 on a linuxMint 17.2, in case that makes a difference.

This is my reproducible example

    > a <- rep("blabla", 5)
    > b <- paste(a, colapse= "X")
    > b
    [1] "blabla X" "blabla X" "blabla X" "blabla X" "blabla X"
    > length(b)
    [1] 5

The way I understand the documentation, I would expect the results be more like "blablaXbla... and the length have a value of 1.

Thanks for your help.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 17:11

Vote count: 0

I have implemented AutoComplete feature in my MVC application but it doesnt seem to work. Could somebody tell whats wrong with my implementation

The Index View Here I have defined the data attributes for autocomplete

<form method="get" action="@Url.Action("Index")" 
    data-otf-ajax="true" data-otf-target="#restaurantList" >

    <input type="search" name="searchTerm" data-otf-autocomplete="@Url.Action("AutoComplete")"/>
    <input type="submit" value="Search" />

</form>

@Html.Partial("_Restaurants", Model)

The otf.js file

$(function ()
{
    var ajaxFormSubmit = function () {
        var $form = $(this);

        var options = {
            url: $form.attr("action"),
            type: $form.attr("method"),
            data: $form.serialize()

        };


        $.ajax(options).done(function (data) {
            var $target = $($form.attr("data-otf-target"));
            $target.replaceWith(data);
        });
    };

    retu false;




    var createAutoComplete = function () {
        var $input = $(this);

        var options = {
            source: $input.attr("data-otf-autocomplete")
        };

        $input.autocomplete(options);

    };

    $("form[data-otf-ajax='true']").submit(ajaxFormSubmit);
    $("input[data-otf-autocomplete]").each(createAutoComplete);

});

The HomeController

 public ActionResult AutoComplete(string searchTerm)
        {
            var model = _db.Restaurants
                        .Where(r => r.Name.StartsWith(searchTerm))
                        .Take(10)
                        .Select(r => new
                        {
                            label = r.Name
                        });
            retu Json(model, JsonRequestBehavior.AllowGet);
        }

asked 46 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 15:59

Vote count: 0

Is there a way to get the result from the Example sheet Columns J:K using a single function?

I.e. is there a way to count unique / disctinct values within QUERY function, or any other single function that would create a pivot-like set of data with two columns?

In the example sheet I have a set of data, which I need to group by one column and count unique values in the other one. There's a workaround there, but it involves two formulas plus another one that would sort it properly (data set is growing and rows get added, so sorting manually is not the best option).

Query function (or, my knowledge of Query function) doesn't seem to be able to count unique values, so it's not working. Googling hasn't helped me much with this.

Example Sheet

asked 20 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 15:59

Vote count: 0

I have followed the instructions here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html

I am specifically trying to do this part:

(Windows platforms) Run the EC2Config service Sysprep. For information about EC2Config, go to Configuring a Windows Instance Using the EC2Config Service. Ensure that Sysprep is configured to generate a random password that can be retrieved from the AWS Management Console

However when I attempt to change this setting, I caot apply the changes. I have run the EC2Config service as administrator. How do I complete this step?

asked 16 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 15:59

Vote count: 0

i install a eclipse mars and download maven plugins but when i create my first app in pom it is showing the error Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-compile)

i try all possibilty but can not resolve so what is the solutation

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 14:09

Vote count: 0

I have used the following code but when i click on the login button i'm redirected to a blank page.in this i have created a login pAGE that checks if the user is present in database.i have not given a sign up page instaed manually added values to the database.in sign-in.html i have given the form and in coectivity.php file i have given the code to check if user and password are present in database. as per code the output should have been "succesfully logged in" or "error could not login" but instead i get a blank page.how do i resolve this.please help!! the php file that coects to db

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 14:09

Vote count: 0

I have vs2013 and ie11 on my system. I have created virtual directory for my web application. I have crystal report version "10.5.3700.0". But when i generated report paging,print btn not loading and report format is also not good.If i run same url in ie8 it works fine.

Some crystal report css and js not loading properly

asked 49 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 14:09

Vote count: 0

I'm working on an open source Rails 4 project that uses PDF Tool Kit ('pdf-forms' gem) to auto-fill PDF forms based on info stored in the app's database. PDFtk requires binaries to be installed, and the instantiated PDFtk model requires a path to the binaries. The path needs to be dynamic so it will work on Heroku, Mac OS X, and Windows, so I figured I'd use the 'which' command and grab the echoed path. But, Windows doesn't use 'which', it uses 'where'.

My best attempt is to detect platform with RbConfig (see below). However, I'm not familiar with the native and portable platforms for Windows, as I'm a Mac user. Is there a way to instead detect if the platform responds to a command, and if so, then execute command?

def pdftk
  # Use path stored in Heroku env vars or else get path to local binaries
  @pdftk ||= PdfForms.new(ENV['PDFTK_PATH'] || local_path) 
end

def local_path
  os = RbConfig::CONFIG['arch']
  if /mswin/ =~ os
    `where pdftk` # Get pdftk filepath, Windows equiv of *nix 'which' command
  else
    `which pdftk` # Get pdftk filepath on POSIX systems
  end
end

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 12:52

Vote count: 0

I`m writing on C++/CLI (Managed C++) in VS2015 IDE. I need to scan every folder, which is currently opened in Explorer, to find there files by needed patte. But first of all, is it possible and if it is, then how it can be done?

I found this one: Search result, but it seems thai it is only for winapi, because i couldn`t even find such reference in VS2015.

Advance thanks.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 12:52

Vote count: 0

I'm a librarian from school. I'm trying to understand how to set up a .py app on apache which using wsgi.

I found a tool called "Majax2", it is a tool that help the library to scrape some standard format from the library catalog and display it on another webpage. You may see the demo page, in the MAJAX output column, it is the output majax2 scrapped(http://libx.lib.vt.edu/services/majax2/bibrecord/2275560) from the library catalog(http://addison.vt.edu/search/.b2275560/.b2275560/1,1,1,E/marc&FF=.b2275560#.VuzyyKd96Uk) and show the bibliographic information or circulation status( 4 copies found: due 09-12-16, available, due 06-11-16, due 10-13-16). See the first record(.b2275560).

code: https://github.com/godmar/majax2

demo page: http://libx.lib.vt.edu/services/majax2/

I install a new Ubuntu 14.04 vm, and follow the steps to set up the environment.

sudo apt-get update
sudo apt-get install python-pip
sudo pip install Django
sudo apt-get install apache2
sudo apt-get install libapache2-mod-wsgi
sudo apt-get install libapache2-mod-wsgi-py3

I put all the code in /var/www/html/services/majax2, so in this folder, I have .htaccess index.html majax2.js and majax.py

And I edit the apache.conf file and add the line at the beneath of the file

  WSGIScriptAlias /services/majax2 /var/www/html/services/majax2/majax2.py/

  Alias /services/majax2/ /var/www/html/services/majax2/
  AddType text/html .py

  <Directory /var/www/html/services/majax2/>
      Order deny,allow
      Allow from all
  </Directory>

Actually, I really have no idea what wsgi and py ... is. I searched the inteet and followed the instructions to set up the environment. But it seems there are still lots of problems to solve.

I got the error message as below

cat /var/log/apache2/error.log
[Sat Mar 19 13:59:05.983780 2016] [mpm_event:notice] [pid 12749:tid 139938135115648] AH00489: Apache/2.4.7 (od_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sat Mar 19 13:59:05.983840 2016] [core:notice] [pid 12749:tid 139938135115648] AH00094: Command line: '/usrche2'

I hope if someone is good at py or have experience using apache wsgi may give me a hand. I need to set up my own environment which can run my own majax service instead of the producer's. Hope you may provide some information or some hint to solve my problem. It's very kind of you if you may tell me which step is wrong or what I should do to make "majax2.py" run. Thanks a lot.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 12:52

Vote count: 0

I need to enable and disable button on checkout page of my online shopping web site.When all fields are filled button should be enabled ,other wise it should be dis enabled. web site

asked 55 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 11:40

Vote count: 0

I don't know what's wrong with it, but my app is searching for nearby Bluetooth devices, but the moment I'm trying to coect to one of these Bluetooth devices, the app crashes.

Please have a look

This is my SearchBTDevice.java. This is the activity that calls the CoectBTDevice activity

package vertex2016.mvjce.edu.bluealert;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattDescriptor;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.bluetooth.BluetoothAdapter;
import android.provider.Settings;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import java.util.Set;

public class SearchBTDevice extends AppCompatActivity {

    public BluetoothAdapter BlueAdapter = BluetoothAdapter.getDefaultAdapter();
    public ArrayAdapter PairedArrayAdapter;
    public ArrayAdapter BTArrayAdapter;
    BluetoothDevice btd;

    public ListView devicesFound;


    private final BroadcastReceiver BTReceiver= new BroadcastReceiver(){

       public void onReceive(Context context, Intent intent)
       {
           String action = intent.getAction();

           if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                   btd = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

                   BTArrayAdapter.add(btd.getName() + "t" + btd.getAddress() + "n");

               }
           }

    };

    IntentFilter filter1 = new IntentFilter(BluetoothDevice.ACTION_FOUND);




    @Override
    protected void onResume() {
        super.onResume();
        this.registerReceiver(BTReceiver,filter1);



    }

    @Override
    protected void onPause() {
        super.onPause();
        BlueAdapter.cancelDiscovery();
        this.unregisterReceiver(BTReceiver);
        Toast.makeText(SearchBTDevice.this, "Discovery Stopped!!", Toast.LENGTH_SHORT).show();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_btdevice);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);




       searchBTDevices();


    }


    public void searchBTDevices()
    {
        if(!BlueAdapter.startDiscovery())
            Toast.makeText(SearchBTDevice.this, "Failed to Start Discovery", Toast.LENGTH_SHORT).show();
        else
            Toast.makeText(SearchBTDevice.this, "Discovery Startred", Toast.LENGTH_SHORT).show();
        BTArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1);
        devicesFound = (ListView)findViewById(R.id.searchpagelistView);
        devicesFound.setAdapter(BTArrayAdapter);
        devicesFound.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent coectedBTintent = new Intent(SearchBTDevice.this, CoectedBTDevice.class);
                coectedBTintent.putExtra("BluetoothDevice", btd);
                startActivity(coectedBTintent);

            }
        });

    }


}

This is my CoectBTDevice.java that attempts to make establish the RFCOMM chael. But this is where my app crashes.

package vertex2016.mvjce.edu.bluealert;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.io.IOException;
import java.util.UUID;

public class CoectedBTDevice extends AppCompatActivity {

    public BluetoothDevice btd;
    public BluetoothSocket btSocket, tempSocket;
    private UUID myUUID;
    ArrayAdapter arr = new ArrayAdapter(this, android.R.layout.simple_list_item_2);
    ListView lv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coected_btdevice);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);

       btd = getIntent().getParcelableExtra("BluetoothDevice");

        coectBT();
        displayStuff();

    }

    public void coectBT()
    {
        Thread myThread = new Thread() {

            public void run()
            {
                tempSocket=null;

                try {
                    tempSocket  = btd.createRfcommSocketToServiceRecord(myUUID);
                } catch (IOException e) {
                    e.printStackTrace();
                }

                BluetoothAdapter.getDefaultAdapter().cancelDiscovery();

                try {
                    btSocket.coect();
                    arr.add("CONNECTED TO-->"+btd.getName());
                } catch (IOException e) {
                    e.printStackTrace();
                    try {
                        btSocket.close();
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }

            }

            public void cancel()
            {
                try {
                    btSocket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        };

        myThread.start();
    }

    void displayStuff()
    {
        lv = (ListView)findViewById(R.id.coectedBTlistView);
        lv.setAdapter(arr);
    }

}

This is what my logcat shows

03-19 10:56:25.072 6086-6086/vertex2016.mvjce.edu.bluealert E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: vertex2016.mvjce.edu.bluealert, PID: 6086
                                                                              java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{vertex2016.mvjce.edu.bluealert/vertex2016.mvjce.edu.bluealert.CoectedBTDevice}: java.lang.IllegalStateException: System services not available to Activities before onCreate()
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)
                                                                                  at android.app.ActivityThread.access$900(ActivityThread.java:154)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                  at android.os.Looper.loop(Looper.java:135)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5292)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                  at com.android.inteal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
                                                                                  at com.android.inteal.os.ZygoteInit.main(ZygoteInit.java:699)
                                                                               Caused by: java.lang.IllegalStateException: System services not available to Activities before onCreate()
                                                                                  at android.app.Activity.getSystemService(Activity.java:5035)
                                                                                  at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)
                                                                                  at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:104)
                                                                                  at vertex2016.mvjce.edu.bluealert.CoectedBTDevice.<init>(CoectedBTDevice.java:24)
                                                                                  at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                                  at java.lang.Class.newInstance(Class.java:1606)
                                                                                  at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420) 
                                                                                  at android.app.ActivityThread.access$900(ActivityThread.java:154) 
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                  at android.os.Looper.loop(Looper.java:135) 
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5292) 
                                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                                  at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                  at com.android.inteal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) 
                                                                                  at com.android.inteal.os.ZygoteInit.main(ZygoteInit.java:699)

asked 49 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 11:40

Vote count: 0

I need full articles from PMC in bulk. Right now I am doing it manually. Is there any easy method for that? Abstracts can be downloaded in bulk from PMC. But I need full text articles for my work.

asked 40 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 11:40

Vote count: 0

There are a number of parameters in this query that are user tune-able, and rather than edit them directly into the sql statement, I want the user to be able to create a few text files, run the query with sqlite3 db.sqlite ".read query.sql" > result.csv, and get the results as a CSV. The problem is that I get different results if I hard-code the select functions in the SQL statement, or if I import the text files and use a select.

Here is the whole SQL file:

.headers off
.mode csv
CREATE TEMP TABLE IF NOT EXISTS zipcodes(zipcode text primary key);
.import zipcodes.txt zipcodes
CREATE TEMP TABLE IF NOT EXISTS dates(year text primary key);
.import dates.txt dates
CREATE TEMP TABLE IF NOT EXISTS history_codes(code text primary key);
.import history_codes.txt history_codes

.print "CALLSIGN,FIRST,LAST,ADDRESS,BOX,CITY,STATE,ZIP"

select
    DISTINCT
    COUNT(*)
    from PUBACC_EN 
        JOIN PUBACC_HD ON PUBACC_EN.unique_system_identifier = PUBACC_HD.unique_system_identifier 
        JOIN PUBACC_AM ON PUBACC_EN.unique_system_identifier = PUBACC_AM.unique_system_identifier
        JOIN PUBACC_AD ON PUBACC_EN.unique_system_identifier = PUBACC_AD.unique_system_identifier
        JOIN PUBACC_HS ON PUBACC_EN.unique_system_identifier = PUBACC_HS.unique_system_identifier
    WHERE (radio_service_code = "HA" or radio_service_code = "HV")
            and PUBACC_AM.callsign <> ''
            and PUBACC_HS.code LIKE ( select code from history_codes )
            and ( street_address <> '' OR po_box <> '')
            and applicant_type_code == "I" 
            and NOT previous_operator_class <> '' 
            and NOT previous_callsign <> ''
    --      and grant_date like ( select year from dates ) 
            and ( grant_date like "%2015%" or grant_date like "%2016%" ) 
            and zip_code IN ( select zipcode from zipcodes )
    ORDER BY PUBACC_AM.callsign ASC
;

DROP TABLE zipcodes;
DROP TABLE dates;
DROP TABLE history_codes;

Notice the lines

--      and grant_date like ( select year from dates ) 
        and ( grant_date like "%2015%" or grant_date like "%2016%" )

The date table contains:

sqlite> select * from dates;
%2015%
%2016%

So it has the same items as the hard coded line. I get a different number of records if I swap statements using Idea. I've only shown the dates item here, but I get different results if I do the same with zipcodes or history_codes as well.

How do I allow the users to edit text files for the parameters and then import that information into the query?

Thank you.

asked 26 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 9:40

Vote count: -2

Wanted to run a program before and after my Windows system reboot from commandline/DOS prompt and script should execute next step after shutdown command. Like: Loop for 1 to 10: 1. Run my first application1/batch1 file. 2. Reboot system (using shutdown command) 3. Run my second application2/batch2 file. End Loop

We can use startup folder to run the second application, but I wanted to have a single script to do things. The script should start from the place where system got rebooted. Is there any way to do so please help?

asked 26 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 9:40

Vote count: 0

java.io.FileNotFoundException: /data/data/com.forward.test/files/1458096313000.stacktrace: open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:416)
    at java.io.FileInputStream.<init>(FileInputStream.java:78)
    at android.app.ContextImpl.openFileInput(ContextImpl.java:643)
    at android.content.ContextWrapper.openFileInput(ContextWrapper.java:159)
    at org.acra.CrashReportPersister.load(SourceFile:65)
    at org.acra.BaseCrashReportDialog.sendCrash(SourceFile:72)
    at org.acra.CrashReportDialog.onClick(SourceFile:141)
    at com.android.inteal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.inteal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.inteal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.EroException: open failed: ENOENT (No such file or directory)
    at libcore.io.Posix.open(Native Method)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
    at libcore.io.IoBridge.open(IoBridge.java:400)

how to know the exception thrown where in my code? from the log, may guess the file is not created, but how to locate which file

asked 26 mins ago

1 Answer

Vote count: 0

The file not found is: /data/data/com.forward.test/files/1458096313000.stacktrace

It seems like it's originating from your acra crash reporter.

It's unable to open the above mentioned stack trace file.

answered 8 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 9:40

Vote count: -3

I need help, i know my logic isn't the greatest right now but i'm trying to test things out so i can understand what my professor is asking for, anyways so i need to use the array classCtr from the header file to keep track of how many seats are actually sold then when the user enters -1 it displays it and so here it what i have so far!

#include<iostream>
#include<string>
#include <iomanip>
using namespace std;

#include "C:UsersbartaOneDriveDocumentsVisual Studio 2015ProjectsProject 4Project 4array.h"

void displayPlane(char msg[], char[ROW][COL]);
void getData(int &, char &);
void salesReport(int classCtr[]);

int main()
{
    int row = 0;
    char seat;

    while (row != -1)
    {

        displayPlane("tChesapeaake Airlines", layout);
        cout << endl;
        getData(row, seat);
        if (row == -1)
            break;
        cout << endl;
        int COL = seat - 'A';
        if (layout[row - 1][COL] == 'X')
        {
            cout << "Sorry this seat is taken" << endl;
        }
        else
        {
            layout[row - 1][COL] = 'X';
        }

    }
    salesReport(classCtr);
    cout << "Have a nice day! " << endl;

    system("pause");
    retu 0;
}
void displayPlane(char msg[] , char[ROW][COL])
{
    cout <<msg << endl;
    for (int r = 0; r < ROW; r++)
    { cout << endl;
    cout << setw(4) << r + 1;
        for (int c = 0; c < COL; c++)
        {
            cout << setw(4) << layout[r][c];
        }
    }
}
void getData(int& row, char& seat)
{
        cout << "Enter row <-1 to stop>  ";
        cin >> row;
        if (row == -1)
            retu;
        cout << "Enter your prefered seat  ";
        cin >> seat;
        seat = toupper(seat);


}
void salesReport(int classCtr[])
{
    for (classCtr[0]; classCtr[0] < 36; ++classCtr[0])
    {
        for (classCtr[1]; classCtr[1] < 36; classCtr[1])
        {
            for (classCtr[2]; classCtr[2] < 36; classCtr[2])
                cout << classCtr[CTR];
        }
    }
}

here is the header file

//arrays for airline problem

const int ROW = 9;
const int COL = 4;
const int CTR = 3;

//initial seats in the plane
    char layout[ROW][COL] = {  { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' },
                            { 'A', 'B', 'C', 'D' }};

    int classCtr[CTR] = {0,0,0};

    string classes[] = {"First Class", "Business Class", "Coach"};

    double fare [] = {500, 300, 100};

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 اسفند 1394 ساعت: 8:25

صفحه بندی